<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - code analysis - /usr/include/boost/date_time/time_resolution_traits.hpp</title>
  <link rel="stylesheet" type="text/css" href="../../../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../../../../index.html">top level</a> - <a href="index.html">usr/include/boost/date_time</a> - time_resolution_traits.hpp<span style="font-size: 80%;"> (source / <a href="time_resolution_traits.hpp.func-sort-c.html">functions</a>)</span></td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">code analysis</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">3</td>
            <td class="headerCovTableEntry">5</td>
            <td class="headerCovTableEntryLo">60.0 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2020-09-11 22:25:26</td>
            <td></td>
            <td class="headerItem">Functions:</td>
            <td class="headerCovTableEntry">1</td>
            <td class="headerCovTableEntry">1</td>
            <td class="headerCovTableEntryHi">100.0 %</td>
          </tr>
          <tr>
            <td class="headerItem">Legend:</td>
            <td class="headerValueLeg">            Lines:
            <span class="coverLegendCov">hit</span>
            <span class="coverLegendNoCov">not hit</span>
</td>
            <td></td>
          </tr>
          <tr><td><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">          Line data    Source code</pre>
<pre class="source">
<a name="1"><span class="lineNum">       1 </span>            : #ifndef DATE_TIME_TIME_RESOLUTION_TRAITS_HPP</a>
<span class="lineNum">       2 </span>            : #define DATE_TIME_TIME_RESOLUTION_TRAITS_HPP
<span class="lineNum">       3 </span>            : 
<span class="lineNum">       4 </span>            : /* Copyright (c) 2002,2003 CrystalClear Software, Inc.
<span class="lineNum">       5 </span>            :  * Use, modification and distribution is subject to the
<span class="lineNum">       6 </span>            :  * Boost Software License, Version 1.0. (See accompanying
<span class="lineNum">       7 </span>            :  * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
<span class="lineNum">       8 </span>            :  * Author: Jeff Garland, Bart Garst
<span class="lineNum">       9 </span>            :  * $Date$
<span class="lineNum">      10 </span>            :  */
<span class="lineNum">      11 </span>            : 
<span class="lineNum">      12 </span>            : 
<span class="lineNum">      13 </span>            : #include &lt;boost/cstdint.hpp&gt;
<span class="lineNum">      14 </span>            : #include &lt;boost/date_time/time_defs.hpp&gt;
<span class="lineNum">      15 </span>            : #include &lt;boost/date_time/int_adapter.hpp&gt;
<span class="lineNum">      16 </span>            : #include &lt;boost/date_time/compiler_config.hpp&gt;
<span class="lineNum">      17 </span>            : 
<span class="lineNum">      18 </span>            : namespace boost {
<span class="lineNum">      19 </span>            : namespace date_time {
<span class="lineNum">      20 </span>            : 
<span class="lineNum">      21 </span>            :   //! Simple function to calculate absolute value of a numeric type
<span class="lineNum">      22 </span>            :   template &lt;typename T&gt;
<span class="lineNum">      23 </span>            :   // JDG [7/6/02 made a template],
<span class="lineNum">      24 </span>            :   // moved here from time_duration.hpp 2003-Sept-4.
<span class="lineNum">      25 </span>            :   inline T absolute_value(T x)
<span class="lineNum">      26 </span>            :   {
<span class="lineNum">      27 </span><span class="lineNoCov">          0 :     return x &lt; 0 ? -x : x;</span>
<span class="lineNum">      28 </span>            :   }
<span class="lineNum">      29 </span>            : 
<span class="lineNum">      30 </span>            :   //! traits struct for time_resolution_traits implementation type
<span class="lineNum">      31 </span>            :   struct time_resolution_traits_bi32_impl {
<span class="lineNum">      32 </span>            :     typedef boost::int32_t int_type;
<span class="lineNum">      33 </span>            :     typedef boost::int32_t impl_type;
<span class="lineNum">      34 </span>            :     static int_type as_number(impl_type i){ return i;}
<span class="lineNum">      35 </span>            :     //! Used to determine if implemented type is int_adapter or int
<span class="lineNum">      36 </span>            :     static bool is_adapted() { return false;}
<span class="lineNum">      37 </span>            :   };
<span class="lineNum">      38 </span>            :   //! traits struct for time_resolution_traits implementation type
<span class="lineNum">      39 </span>            :   struct time_resolution_traits_adapted32_impl {
<span class="lineNum">      40 </span>            :     typedef boost::int32_t int_type;
<span class="lineNum">      41 </span>            :     typedef boost::date_time::int_adapter&lt;boost::int32_t&gt; impl_type;
<span class="lineNum">      42 </span>            :     static int_type as_number(impl_type i){ return i.as_number();}
<span class="lineNum">      43 </span>            :     //! Used to determine if implemented type is int_adapter or int
<span class="lineNum">      44 </span>            :     static bool is_adapted() { return true;}
<span class="lineNum">      45 </span>            :   };
<span class="lineNum">      46 </span>            :   //! traits struct for time_resolution_traits implementation type
<span class="lineNum">      47 </span>            :   struct time_resolution_traits_bi64_impl {
<span class="lineNum">      48 </span>            :     typedef boost::int64_t int_type;
<span class="lineNum">      49 </span>            :     typedef boost::int64_t impl_type;
<span class="lineNum">      50 </span>            :     static int_type as_number(impl_type i){ return i;}
<span class="lineNum">      51 </span>            :     //! Used to determine if implemented type is int_adapter or int
<span class="lineNum">      52 </span>            :     static bool is_adapted() { return false;}
<span class="lineNum">      53 </span>            :   };
<span class="lineNum">      54 </span>            :   //! traits struct for time_resolution_traits implementation type
<span class="lineNum">      55 </span>            :   struct time_resolution_traits_adapted64_impl {
<span class="lineNum">      56 </span>            :     typedef boost::int64_t int_type;
<span class="lineNum">      57 </span>            :     typedef boost::date_time::int_adapter&lt;boost::int64_t&gt; impl_type;
<span class="lineNum">      58 </span>            :     static int_type as_number(impl_type i){ return i.as_number();}
<span class="lineNum">      59 </span>            :     //! Used to determine if implemented type is int_adapter or int
<span class="lineNum">      60 </span>            :     static bool is_adapted() { return true;}
<span class="lineNum">      61 </span>            :   };
<span class="lineNum">      62 </span>            : 
<span class="lineNum">      63 </span>            :   template&lt;typename frac_sec_type,
<span class="lineNum">      64 </span>            :            time_resolutions res,
<span class="lineNum">      65 </span>            : #if (defined(BOOST_MSVC) &amp;&amp; (_MSC_VER &lt; 1300))
<span class="lineNum">      66 </span>            :            boost::int64_t resolution_adjust,
<span class="lineNum">      67 </span>            : #else
<span class="lineNum">      68 </span>            :            typename frac_sec_type::int_type resolution_adjust,
<span class="lineNum">      69 </span>            : #endif
<span class="lineNum">      70 </span>            :            unsigned short frac_digits,
<span class="lineNum">      71 </span>            :            typename var_type = boost::int32_t &gt;
<span class="lineNum">      72 </span>            :   class time_resolution_traits {
<span class="lineNum">      73 </span>            :   public:
<span class="lineNum">      74 </span>            :     typedef typename frac_sec_type::int_type fractional_seconds_type;
<span class="lineNum">      75 </span>            :     typedef typename frac_sec_type::int_type tick_type;
<span class="lineNum">      76 </span>            :     typedef typename frac_sec_type::impl_type impl_type;
<span class="lineNum">      77 </span>            :     typedef var_type  day_type;
<span class="lineNum">      78 </span>            :     typedef var_type  hour_type;
<span class="lineNum">      79 </span>            :     typedef var_type  min_type;
<span class="lineNum">      80 </span>            :     typedef var_type  sec_type;
<span class="lineNum">      81 </span>            : 
<span class="lineNum">      82 </span>            :     // bring in function from frac_sec_type traits structs
<span class="lineNum">      83 </span>            :     static fractional_seconds_type as_number(impl_type i)
<span class="lineNum">      84 </span>            :     {
<span class="lineNum">      85 </span>            :       return frac_sec_type::as_number(i);
<span class="lineNum">      86 </span>            :     }
<span class="lineNum">      87 </span>            :     static bool is_adapted()
<span class="lineNum">      88 </span>            :     {
<span class="lineNum">      89 </span>            :       return frac_sec_type::is_adapted();
<span class="lineNum">      90 </span>            :     }
<span class="lineNum">      91 </span>            : 
<span class="lineNum">      92 </span>            :     //Would like this to be frac_sec_type, but some compilers complain
<span class="lineNum">      93 </span>            : #if (defined(BOOST_MSVC) &amp;&amp; (_MSC_VER &lt; 1300))
<span class="lineNum">      94 </span>            :     BOOST_STATIC_CONSTANT(boost::int64_t, ticks_per_second = resolution_adjust);
<span class="lineNum">      95 </span>            : #else
<span class="lineNum">      96 </span>            :     BOOST_STATIC_CONSTANT(fractional_seconds_type, ticks_per_second = resolution_adjust);
<span class="lineNum">      97 </span>            : #endif
<span class="lineNum">      98 </span>            : 
<span class="lineNum">      99 </span>            :     static time_resolutions resolution()
<span class="lineNum">     100 </span>            :     {
<span class="lineNum">     101 </span>            :       return res;
<span class="lineNum">     102 </span>            :     }
<span class="lineNum">     103 </span>            :     static unsigned short num_fractional_digits()
<span class="lineNum">     104 </span>            :     {
<span class="lineNum">     105 </span>            :       return frac_digits;
<span class="lineNum">     106 </span>            :     }
<span class="lineNum">     107 </span>            :     static fractional_seconds_type res_adjust()
<span class="lineNum">     108 </span>            :     {
<span class="lineNum">     109 </span>            :       return resolution_adjust;
<a name="110"><span class="lineNum">     110 </span>            :     }</a>
<span class="lineNum">     111 </span>            :     //! Any negative argument results in a negative tick_count
<span class="lineNum">     112 </span><span class="lineCov">      62006 :     static tick_type to_tick_count(hour_type hours,</span>
<span class="lineNum">     113 </span>            :                                    min_type  minutes,
<span class="lineNum">     114 </span>            :                                    sec_type  seconds,
<span class="lineNum">     115 </span>            :                                    fractional_seconds_type  fs)
<span class="lineNum">     116 </span>            :     {
<span class="lineNum">     117 </span><span class="lineCov">      62006 :       if(hours &lt; 0 || minutes &lt; 0 || seconds &lt; 0 || fs &lt; 0)</span>
<span class="lineNum">     118 </span>            :       {
<span class="lineNum">     119 </span>            :         hours = absolute_value(hours);
<span class="lineNum">     120 </span>            :         minutes = absolute_value(minutes);
<span class="lineNum">     121 </span>            :         seconds = absolute_value(seconds);
<span class="lineNum">     122 </span>            :         fs = absolute_value(fs);
<span class="lineNum">     123 </span>            :         return (((((fractional_seconds_type(hours)*3600)
<span class="lineNum">     124 </span>            :                    + (fractional_seconds_type(minutes)*60)
<span class="lineNum">     125 </span><span class="lineNoCov">          0 :                    + seconds)*res_adjust()) + fs) * -1);</span>
<span class="lineNum">     126 </span>            :       }
<span class="lineNum">     127 </span>            : 
<span class="lineNum">     128 </span>            :       return (((fractional_seconds_type(hours)*3600)
<span class="lineNum">     129 </span>            :                + (fractional_seconds_type(minutes)*60)
<span class="lineNum">     130 </span><span class="lineCov">      62006 :                + seconds)*res_adjust()) + fs;</span>
<span class="lineNum">     131 </span>            :     }
<span class="lineNum">     132 </span>            : 
<span class="lineNum">     133 </span>            :   };
<span class="lineNum">     134 </span>            : 
<span class="lineNum">     135 </span>            :   typedef time_resolution_traits&lt;time_resolution_traits_adapted32_impl, milli, 1000, 3 &gt; milli_res;
<span class="lineNum">     136 </span>            :   typedef time_resolution_traits&lt;time_resolution_traits_adapted64_impl, micro, 1000000, 6 &gt; micro_res;
<span class="lineNum">     137 </span>            :   typedef time_resolution_traits&lt;time_resolution_traits_adapted64_impl, nano,  1000000000, 9 &gt; nano_res;
<span class="lineNum">     138 </span>            : 
<span class="lineNum">     139 </span>            : 
<span class="lineNum">     140 </span>            : } } //namespace date_time
<span class="lineNum">     141 </span>            : 
<span class="lineNum">     142 </span>            : 
<span class="lineNum">     143 </span>            : 
<span class="lineNum">     144 </span>            : #endif
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.12</a></td></tr>
  </table>
  <br>

</body>
</html>
